#ifndef DATA_DEVICE_H
#define DATA_DEVICE_H

#include <string>

class dataDevice
{
	int fd;

public:
	virtual ~dataDevice(){}

	int getFd() const;
	void setFd(int fd);
	virtual bool open() = 0;
	virtual ssize_t read(void *buffer, size_t size) = 0;
	virtual ssize_t write(void *buffer, size_t size) = 0;
};

class ethernetDataDevice : public dataDevice
{
	char const * addr;
	int port;

public:
	ethernetDataDevice(const char* addr, int port);
	bool open();
	ssize_t read(void *buffer, size_t size);
	ssize_t write(void *buffer, size_t size);
	~ethernetDataDevice();
};

class serialDataDevice : public dataDevice
{
	char const * serialName;
	std::string speed;

public:
	serialDataDevice(const char* serialName, std::string speed);
	bool open();
	ssize_t read(void *buffer, size_t size);
	ssize_t write(void *buffer, size_t size);
	~serialDataDevice();
};

#endif  //DATA_DEVICE_H
